package com.banfan.almond.web.security;

import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;

@Data
public class SecurityUser implements UserDetails {

    private final Integer userUid;
    private final Integer roleUid;
    private final String username;
    private final String password;
    private final boolean enable;
    private final Collection<GrantedAuthority> authorities;


    public SecurityUser(Integer uid,Integer roleUid, String username, String password, boolean enable, List<GrantedAuthority> authorities) {
        this.userUid = uid;
        this.roleUid = roleUid;
        this.username = username;
        this.password = password;
        this.enable = enable;
        this.authorities = authorities;
    }


    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return this.authorities;
    }

    @Override
    public String getPassword() {
        return this.password;
    }

    @Override
    public String getUsername() {
        return this.username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return this.enable;
    }
}
